We establish a generalized thermodynamic formalism for topological Markov shifts with a countable number of states. We offer a definition of topological pressure and show that it satisfies a variational principle for the metric entropies. The pressure of $\phi =0$ is the Gurevic entropy. This pressure may be finite even if the topological entropy is infinite. Let $L_\phi$ denote the Ruelle operator for $\phi$. We offer a definition of positive recurrence for $\phi$ and show that it is a necessary and sufficient condition for a Ruelle–Perron–Frobenius theorem to hold: there exist a $\sigma$-finite measure $\nu $, a continuous function $h>0$ and $\lambda >0$ such that $L_\phi ^{*}\nu =\lambda \nu$, $L_\phi h=\lambda h $ and $\lambda ^{-n}L_\phi ^nf\rightarrow h\int f\,d\nu$ for suitable functions $f$. We show that under certain conditions this convergence is uniform and exponential. We prove a decomposition theorem for positive recurrent functions and construct conformal measures and equilibrium measures. We give complete characterization of the situation when the equilibrium measure is a Gibbs measure. We end by giving examples where positive recurrence can be verified. These include functions of the form
$$
\phi =\log f\left( \cfrac{1}{x_0+ \cfrac{1}{x_1+\dotsb }}\right),
$$
where $f$ is a suitable function on a suitable shift $X$.